import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
import VueSetupExtend from 'vite-plugin-vue-setup-extend';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers';

export default defineConfig({
    base: './',
    server: {
        port: 3001,
        https: false,
        host: '0.0.0.0',
        open: true,
        cors: true,
        proxy: {
            '/api': {
                // 目标服务器的URL
                target: 'http://localhost:8089',
                // 是否需要在请求中包含host头
                changeOrigin: true,
                // 路径重写规则
                rewrite: (path) => path.replace(/^\/api/, '/api')
            }
        }
    },
    plugins: [
        vue(),
        VueSetupExtend(),
        AutoImport({
            resolvers: [ElementPlusResolver()]
        }),
        Components({
            resolvers: [ElementPlusResolver()]
        })
    ],
    optimizeDeps: {
        include: ['schart.js']
    },
    resolve: {
        alias: {
            '@': '/src',
            '~': '/src/assets'
        }
    },
    define: {
        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "true",
    },
});
